<template>
  <div class="author-container">
    <!-- 头部图片 -->
    <div class="pic-box" @click="$router.push('/picturewall/' + id)">
      <div class="pic" :style="{ backgroundImage: `url(${authorInfo.mini_share_img_url ? authorInfo.mini_share_img_url : ''})` }"></div>
      <div class="side-count-box">
        <div class="author-header">
          <div class="post-pic">
            <img :src="authorInfo.cover_user && authorInfo.cover_user.avatar" alt="" />
          </div>
          <span class="desc">占领了封面</span>
        </div>
        <div class="pic-count">
          <span class="icon"></span>
          <span class="count">{{ authorInfo.pic_count }}</span>
        </div>
      </div>
    </div>
    <!-- 地址信息 -->
    <div class="address-info">
      <!-- 标题 -->
      <div class="title-desc">{{ authorInfo.name }}</div>
      <!-- 人均价格 -->
      <div class="avg-price" v-if="authorInfo.avg_price">
        <span class="icon">
          <img src="@/assets/head/price_icon.jpg" alt="" />
        </span>
        <span class="price">人均￥{{ authorInfo.avg_price }}</span>
      </div>
      <!-- 营业时间 -->
      <div class="time-box" v-if="authorInfo.hours">
        <span class="icon">
          <img src="@/assets/head/fU.png" alt="" />
        </span>
        <span class="time-desc">营业时间：{{ authorInfo.hours }}</span>
      </div>
      <!-- 详细地址 -->
      <div class="address-box">
        <div class="address">
          <span class="icon">
            <img src="@/assets/head/dY.png" alt="" />
          </span>
          <span class="address-desc">{{ authorInfo.address }}</span>
        </div>
        <!-- 导航 -->
        <div class="navigation">
          <span class="icon">
            <img src="@/assets/arrow/TR.png" alt="" />
          </span>
          <span>导航</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { bus } from '@/utils/bus/bus'
export default {
  props: {
    authorInfo: Object,
    id: [Number, String]
  },
  beforeDestroy() {
    bus.$emit('title', this.authorInfo.name)
  }
}
</script>

<style lang="less" scoped>
.author-container {
  padding: 10px;
  background-color: #fff;

  .pic-box {
    height: 160px;
    width: 100%;
    position: relative;
    border-radius: 15px;
    overflow: hidden;

    .pic {
      height: 100%;
      background-size: 100% 170%;
      background-repeat: no-repeat;
      background-position: center;
    }
    .side-count-box {
      position: absolute;
      bottom: 0;
      left: 0;
      display: flex;
      height: 40px;
      z-index: 1;
      width: 100%;
      padding: 0 10px;
      justify-content: space-between;
      align-items: center;

      .author-header {
        display: flex;
        align-items: center;
        height: 100%;

        .post-pic {
          height: 30px;
          width: 30px;

          img {
            height: 100%;
            width: 100%;
          }
        }
        .desc {
          margin-left: 5px;
          font-size: 12px;
          color: #fff;
          font-weight: 600;
        }
      }
      .pic-count {
        padding: 5px 10px;
        border-radius: 999px;
        color: #fff;
        font-size: 12px;
        display: flex;
        align-items: center;
        background-color: rgba(0, 0, 0, 0.5);

        .icon {
          height: 12px;
          width: 12px;
          background-size: cover;
          background-repeat: no-repeat;
          background-image: url('@/assets/head/7X.png');
        }

        .count {
          margin-left: 3px;
        }
      }
    }
  }
  .address-info {
    padding: 10px;
    color: #404040;
    font-weight: 600;
    font-size: 12px;
    line-height: 20px;

    .title-desc {
      padding: 10px 0;
      font-size: 18px;
      font-weight: bolder;
      color: #333333;
    }

    .avg-price,
    .time-box,
    .address-box {
      display: flex;
      align-items: center;
      padding: 3px 0;

      &.address-box {
        justify-content: space-between;
        .address {
          display: flex;
          align-items: center;
        }
        .navigation {
          display: flex;
          align-items: center;

          span {
            font-size: 14px;
            color: #87bfe7;
          }
          .icon {
            height: 16px;
            width: 16px;

            img {
              height: 100%;
              width: 100%;
            }
          }
        }
      }

      &.avg-price {
        .icon {
          height: 12px;
          width: 12px;
          transform: translateY(-2px);
        }
      }

      .icon {
        height: 14px;
        width: 14px;
        margin-right: 5px;

        img {
          height: 100%;
          width: 100%;
        }
      }
    }
  }
}
</style>
